package com.carreirati.evaluation;

import com.carreirati.evaluation.domain.AppraisalResults;
import com.carreirati.evaluation.domain.VwGetEvaluationResultsByQuestionParameter;
import java.util.List;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.roo.addon.web.mvc.controller.json.RooWebJson;
import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/vwgetevaluationresultsbyquestionparameters")
@Controller
@RooWebScaffold(path = "vwgetevaluationresultsbyquestionparameters", formBackingObject = VwGetEvaluationResultsByQuestionParameter.class)
@RooWebJson(jsonObject = VwGetEvaluationResultsByQuestionParameter.class)
public class VwGetEvaluationResultsByQuestionParameterController {

    @RequestMapping(value = "/find{appraisalId}", headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<java.lang.String> findJson(@PathVariable("appraisalId") long appraisalId, @RequestParam("questionId") long questionId) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        List<VwGetEvaluationResultsByQuestionParameter> result = VwGetEvaluationResultsByQuestionParameter.findAllVwGetEvaluationResultsByQuestionParameters(appraisalId, questionId);
        return new ResponseEntity<String>(VwGetEvaluationResultsByQuestionParameter.toJsonArray(result), headers, HttpStatus.OK);
    }
    
    @RequestMapping(value = "/findselectedparameter{appraisalId}", headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<java.lang.String> findselectedparameterJson(@PathVariable("appraisalId") long appraisalId, @RequestParam("aux") String aux) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        String[] x = aux.split(";");
        long questionId = Long.valueOf(x[0]);
        long parameterId = Long.valueOf(x[1]);
        List<VwGetEvaluationResultsByQuestionParameter> result = VwGetEvaluationResultsByQuestionParameter.findAllVwGetEvaluationResultsByQuestionParameterId(appraisalId, questionId, parameterId);
        return new ResponseEntity<String>(VwGetEvaluationResultsByQuestionParameter.toJsonArray(result), headers, HttpStatus.OK);
    }
}
